﻿using System;
using System.Windows.Data;

namespace mal.WP7.FreeRemote.Converters
{
    public class BoxNumberConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int boxNumber = (int)value;
            int currentBoxNumber = int.Parse((string)parameter);

            return boxNumber == currentBoxNumber;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool isChecked = (bool)value;
            int currentBoxNumber = int.Parse((string)parameter);

            if (isChecked)
            {
                return currentBoxNumber;
            }
            else
            {
                return 0;
            }
        }

        #endregion
    }
}
